Adding array operator long vector tests to HLK#7887
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
eb5a56c to
a5918e7
Compare
| OutputVector[IndexList[i]] = Input1[IndexList[i]]; | ||
| uint index = (uint)(IndexList[i]); |
There was a problem hiding this comment.
Did you mean this? Otherwise index is not used.
| OutputVector[IndexList[i]] = Input1[IndexList[i]]; | |
| uint index = (uint)(IndexList[i]); | |
| uint index = (uint)(IndexList[i]); | |
| OutputVector[index] = Input1[index]; |
| uint Modifier = (uint) Input2[0]; | ||
| uint IndexList[6] = {0 + Modifier, OutNum - 1 + Modifier, 1 + Modifier, OutNum - 2 + Modifier, OutNum / 2 + Modifier, OutNum / 2 + 1 + Modifier}; |
There was a problem hiding this comment.
Typically you can use the name Zero for clarity. Also, if you add this Zero to the initialization of index below instead of the init list, the code would be a bit simpler, and equivalent. Then it's easier to compare IndexList between static/dynamic cases. If you had a common location, you could even share the code.
|
|
||
| #if IS_UNARY_OP | ||
| #if TEST_ARRAY_OPERATOR_STATIC_ACCESS | ||
| uint IndexList[6] = {0, OutNum - 1, 1, OutNum - 2, OutNum / 2, OutNum / 2 + 1}; |
There was a problem hiding this comment.
The count could be a constant, then used later instead of 6 for clarity.
Plus the IndexList could be const and formatted to make it easier to see the pattern.
| uint IndexList[6] = {0, OutNum - 1, 1, OutNum - 2, OutNum / 2, OutNum / 2 + 1}; | |
| const uint IndexCount = 6; | |
| const uint IndexList[IndexCount] = { | |
| 0, OutNum - 1, | |
| 1, OutNum - 2, | |
| OutNum / 2, OutNum / 2 + 1 | |
| }; |
| vector<OUT_TYPE, OutNum> OutputVector = 0; | ||
| uint End = min(OutNum, 6); | ||
|
|
||
| [unroll]for(uint i = 0; i < 6; ++i) { |
There was a problem hiding this comment.
Loop uses 6 instead of End.
| [unroll]for(uint i = 0; i < 6; ++i) { | |
| [unroll]for(uint i = 0; i < End; ++i) { |
| HLSLBool_t() : Val(0) {} | ||
| HLSLBool_t(int32_t Val) : Val(Val) {} | ||
| HLSLBool_t(bool Val) : Val(Val) {} | ||
| explicit HLSLBool_t(float Val) : Val(Val) {} |
There was a problem hiding this comment.
Why is adding this operator necessary? I don't see where it's used.
|
|
||
| size_t IndexList[6] = { | ||
| 0, VectorSize - 1, 1, VectorSize - 2, VectorSize / 2, VectorSize / 2 + 1}; | ||
| for (size_t i = 0; i < 6; ++i) |
There was a problem hiding this comment.
I suppose if you're going to use min(VectorSize, 6) in HLSL for the loop count, you should do so here too. The only difference for vectors of length 3 to 5 is redundant operations on short vectors. If you use a vector length of 1 or 2, this will index out-of-bounds at VectorSize - 2 for length 1 and VectorSize / 2 + 1 for lengths 1 and 2.
damyanp
left a comment
There was a problem hiding this comment.
I think this LGTM. It took me quite a while to try and figure out what these tests were doing. I wonder if there are some short, directed, comments that could help explain things?
alsepkow
left a comment
There was a problem hiding this comment.
LGTM. A few minor nits and a suggestion to avoid comparing a bunch of extra zeros.
| size_t IndexList[IndexCount] = { | ||
| 0, VectorSize - 1, 1, VectorSize - 2, VectorSize / 2, VectorSize / 2 + 1}; | ||
| size_t End = std::min(VectorSize, IndexCount); | ||
| for (size_t i = 0; i < End; ++i) |
| #if TEST_ARRAY_OPERATOR | ||
| // This test case is for testing array operator []. | ||
| // It tests static array access with a compile time constant index array. | ||
| // And dynamic access, by introducing a runtime dependency that prevents the |
There was a problem hiding this comment.
very minor nit: Change 'And' to 'Or' to further clarify its one or the other at a time.
| // And dynamic access, by introducing a runtime dependency that prevents the | |
| // Or dynamic access, by introducing a runtime dependency that prevents the |
| uint End = min(OutNum, IndexCount); | ||
|
|
||
| #if DYNAMIC_ACCESS | ||
| uint Zero = (uint) Input2[0]; |
| static std::vector<T> buildExpectedArrayAccess(const InputSets<T> &Inputs) { | ||
| const size_t VectorSize = Inputs[0].size(); | ||
| std::vector<T> Expected; | ||
| Expected.resize(VectorSize); |
There was a problem hiding this comment.
Is there a reason you opted to zero an expected vector for the elements we aren't testing vs just setting the expected output size to 6?
You could avoid verifying a bunch of zeros by doing that. And if I recall correctly, all you will need to do is set the size of Expected to 6 here. The framework we built dispatches calls to other functions based on the number of elements in the Expected vector. And you can set OutNum in the shader to 6 with logic similar to how it's changed for the reduction op.
There was a problem hiding this comment.
The test read and write at different indexes on which vector size. This is done to provide GEP instruction with index to access at the beginning, middle and end of vector. Forcing that to be 6 means we will need to store the that at I always, making the storing of elements to always be static.
I could make the IndexVector to be 0 to 5, but that reduces the scope where we test GEP calc for larger vectors
There was a problem hiding this comment.
Great point! I wasn't considering the storing portion when I asked that. I wonder if a comment saying that is helpful for a little documentation on that being the intent.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This patch is adding array operator long vector test to HLK. There are 3 scenarios that were identified when doing those tests:
extracelementandinsertelement.Closes: #7618